
//提交表单的方法
	$('#btnSubmit').click(function(){
		$('#updateForm').validator({
			
			rules: {
				shouhuolxdh:[/^-?\d{0,8}\.?\d{0,4}$/,'请填写正确手机或座机格式'],
			},
			fields: {
				'mingcheng': '诊所名称: required;length(1~32)',
				'shouhuolxdh': 'length(0~15);',
				'leixing': 'checked',
				'dizhi': 'length(1~100)',
				'yiliaojgbh': 'length(1~20)'
			},
			valid: function(form){
				$.ajax({
					url:path+'/zhensuo/xiugaizs',
					type:'POST',
					 beforeSend: function () {
	 					$("#loading").css({"display":"block","z-index":"5"})
	 					 },
	 					 complete: function () {
	 						$("#loading").css({"display":"none","z-index":"5"})
	 					 },
					data:$('#updateForm').serializeArray(),
					success:function(data) {
	 						var sjc= new Date().getTime();
							var msg='诊所信息保存成功';
							msg=encodeURI(encodeURI(msg));
							window.location.href=path+'/jump/toZhensuo?msg='+msg+'&sjc='+sjc;
					}
				});	
			}
		});
		
		var shengfen = $('#province').val();
		var chengshi = $('#citys').val();
		var quxian = $('#county').val();
		var msg = {
				"shengfen": shengfen,
				"chengshi": chengshi,
				"quxian": quxian
		}
		$.ajax({
			url: './yibaokhxz/getCanbaodtcqhBySfAndCsAndQx',
			type: 'post',
			data: msg,
			async: false,
			success: function(data){
				var canbaodtcqh = {
						"canbaodtcqh": data
				}
				if(data != ''){
					$.ajax({
						url: './yibaokhxz/updateCanbaodtcqhBySfAndCsAndQx',
						type: 'post',
						data: canbaodtcqh,
						success: function(){
							console.log("OK");
						}
					});
				}
			}
		});
		
	});	
		 
	//点击性别时radio属性跟着lable属性变化
	$(".g-radio-shield label:not(.g-label-name)").on("click",function(){
	  $(this).addClass("on").siblings().removeClass("on");
	});
	//图片上传
	//$('#imgid').attr('src',path+'/download/doTempDownload');
	function ajaxFileUpload() { 
		$.ajaxFileUpload( {
			url : path+'/upload/doUpload',//用于文件上传的服务器端请求地址  
	        secureuri : false,//一般设置为false  
	        fileElementId : 'avatarInput',//文件上传控件的id属性  
	        dataType : 'text',
	        success : function(data){ //服务器成功响应处理函数
	         	var start = data.indexOf("{");
	         	var end = data.indexOf("}");
				data = data.substring(start,end+1);
				var dataset = $.parseJSON(data);
				$('#imgid').attr('src',path+'/download/doTempDownload?filepath='+dataset.filepath);            		
	 		}
		});
		return false;  
	}
	
	$(function(){
		var phone = $('#phone').val();
		console.log(phone);
		if(phone == '' || phone == '(NULL)'){
			$('#phone').val('');
		}
	});
	